Updating files with a Perforce trigger before submit [migrated]

Posted by phantom-99w on Server Fault See other posts from Server Fault or by phantom-99w
Published on 2014-06-10T20:23:48Z Indexed on 2014/06/10 21:27 UTC
Read the original article Hit count: 202

Filed under:
|
|

I understand that this question has, in essence, already been asked, but that question did not have an unequivocal answer, so please bear with me.

Background: In my company, we use Perforce submission numbers as part of our versioning. Regardless of whether this is a correct method or not, that is how things are. Currently, many developers do separate submissions for code and documentation: first the code and then the documentation to update the client-facing docs with what the new version numbers should be. I would like to streamline this process.

My thoughts are as follows: create a Perforce trigger (which runs on the server side) which scans the submitted documentation files (such as .txt) for a unique term (such as #####PERFORCE##CHANGELIST##NUMBER###ROFL###LOL###WHATEVER#####) and then replaces it with the value of what the change list would be when submitted. I already know how to determine this value. What I cannot figure out, is how or where to update the files.

I have already determined that using the change-content trigger (whether possible or not), which

"fire[s] after changelist creation and file transfer, but prior to committing the submit to the database",

is the way to go. At this point the files need to exist somewhere on the server. How do I determine the (temporary?) location of these files from within, say, a Python script so that I can update or sed to replace the placeholder value with the intended value? The online documentation for Perforce which I have found so far have not been very explicit on whether this is possible or how the mechanics of a submission at this stage would work.

© Server Fault or respective owner

Related posts about python

Related posts about trigger